package base

import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger

/**
 * A thread factory for build a new Thread
 */
class PipeThreadFactory : ThreadFactory {

    companion object {
        private val threadNumber = AtomicInteger(1)
    }

    override fun newThread(r: Runnable): Thread {
        val thread = Thread(r)
        thread.name = "PIPE-Consumer-Thread-${threadNumber.getAndIncrement()}"
        thread.isDaemon = true
        return thread
    }
}